<template>
  <div class="page-detail">
    <el-row style="margin-top: 30px">
      <Summa :meta="product"/>
    </el-row>
    <el-row class="m-title">
      <el-col :span="24">
        <h3>商家团购及优惠</h3>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="24">
        <list
          v-if="login"
          :list="list"/>
        <div
          v-else
          class="deal-need-login">
          <img
            src="//p0.meituan.net/codeman/56a7d5abcb5ce3d90fc91195e5b5856911194.png"
            alt="登录查看">
          <span>请登录后查看详细团购优惠</span>
          <el-button
            type="primary"
            round>
            <a href="/login">立即登录</a>
          </el-button>
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import Summa from '@/components/detail/summary'
import List from '@/components/detail/list'

export default {
  name: 'Detail',
  components: {
    Summa,
    List
  },
  data() {
    return {
      product: {},
      list: [],
      login: false
    }
  },
  computed: {},
  async asyncData(ctx) {
    const { id } = ctx.query
    const {
      status,
      data: { product, login }
    } = await ctx.$axios.get(`/search/product?id=${id}`)
    return {
      product: status == 200 ? product : {},
      login
    }
  }
}
</script>


<style lang="scss">
@import '@/assets/css/detail/index.scss';
</style>
